package com.mtnz.njk.Controller;

import com.mtnz.njk.Service.ResearchManagerService;
import com.mtnz.njk.model.ResearchManageModel;
import com.mtnz.njk.result.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
* @Description:    研究院帖子控制层
* @Author:         ZPX
* @CreateDate:     2019/8/13 9:10
* @Version:        1.0
*/
@RestController
@CrossOrigin
@RequestMapping("/research")
public class ResearchManagerController {

    @Autowired
    ResearchManagerService researchManagerService;

    /**
     * 转移研究院帖子
     * @param productId 产品ID
     * @param researchId 研究院ID
     * @return
     */
    @PostMapping("/shiftResearch")
    public ResponseResult shiftResearch(String productId,String researchId)throws Exception{
     return researchManagerService.shiftResearch(productId,researchId);
    }

    /**
     * 删除帖子
     * @param researchId
     * @return
     */
    @PostMapping("/deleteResearch")
    public ResponseResult deleteResearch(String researchId){
        return  researchManagerService.deleteResearch(researchId);
    }

    /**
     * 编辑研究院帖子
     * @param researchId 帖子ID
     * @param subject 标题
     * @param topStatus 是否置顶
     * @param coverImg 封面图
     * @param shareImg 分享图
     * @param content 内容
     * @return
     */
    @PostMapping("/updateResearch")
    public ResponseResult updateResearch(String productId, String cpmImg, String activeImg, String activeStatus, String researchId, String subject, String topStatus, String coverImg, String shareImg, String content, String activeEndTime)throws Exception{
        return  researchManagerService.updateResearch(productId,cpmImg,activeImg,activeStatus,researchId, subject, topStatus, coverImg, shareImg, content,activeEndTime);
    }


    /**
     * 添加帖子
     * @param researchModel
     * @return
     * @throws Exception
     */
    @PostMapping("/addResearch")
    public ResponseResult addResearch(@RequestBody ResearchManageModel researchModel) throws Exception {
        return  researchManagerService.addResearch(researchModel);
    }

    /**
     * 修改是否为精
     * @param researchId
     * @param cream
     * @return
     * @throws Exception
     */
    @PostMapping("/updateCream")
    public ResponseResult updateCream(String researchId,String cream)throws Exception{
        return researchManagerService.updateCream(researchId,cream);
    }

    /**
     * 删除评论
     * @param commentResearchId
     * @return
     */
    @PostMapping("/delComment")
    public ResponseResult delComment(String commentResearchId){
        return researchManagerService.delComment(commentResearchId);
    }

    /**
     * 添加评论
     * @param researchId
     * @param userId
     * @param message
     * @param img
     * @return
     */
    @PostMapping("/addCommentResearch")
    public ResponseResult addCommentResearch(String researchId, String userId, String message, String img){
        return researchManagerService.addCommentResearch(researchId, userId, message, img);
    }

    /**
     * 回复评论
     * @param userId
     * @param researchId
     * @param message
     * @param commentResearchId
     * @return
     */
    @PostMapping("/commentResearchReply")
    public ResponseResult commentResearchReply(String userId, String researchId, String message, String commentResearchId) {
        return researchManagerService.commentResearchReply(userId,researchId,message,commentResearchId);
    }

    /**
     * 回复评论回复
     * @param userId
     * @param researchId
     * @param message
     * @param pid
     * @return
     */
    @PostMapping("commentResearchReplyS")
    public ResponseResult commentResearchReplyS(String userId, String researchId, String message,String replyId,String pid) {
        return  researchManagerService.commentResearchReplys(userId,researchId,message,replyId,pid);
    }

    /**
     * 评论列表
     * @param researchId
     * @param userId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @PostMapping("/showReply")
    public ResponseResult showReply(Integer researchId,String userId, @RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "10") Integer pageSize)throws Exception{
        return researchManagerService.showReply(researchId, userId, pageNum, pageSize);
    }

    /**
     * 研究院统计
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param status  0月1年
     * @return
     */
    @PostMapping("/researchStatistics")
    public ResponseResult ResearchStatistics(String startTime,String endTime,String status)throws Exception{
        return researchManagerService.researchStatistics(startTime, endTime, status);
    }

    /**
     * 分享运营导出excel
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("/exportExcel")
    public ResponseResult exportExcel(HttpServletResponse response, String startTime, String endTime) throws Exception {
        return researchManagerService.exportExcel(response,startTime, endTime);
    }

    /**
     * 研究社分享列表
     * @param communityId
     * @return
     * @throws Exception
     */
    @PostMapping("/researchShareList")
    public ResponseResult researchShareList(String communityId,String communityType,@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "10") Integer pageSize)throws Exception{

        return researchManagerService.researchShareList(communityId,communityType,pageNum,pageSize);
    }

    /**
     * 社区广告轮播图列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @PostMapping("/researchBanner")
    public ResponseResult researchBanner(@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "10") Integer pageSize){
        return researchManagerService.researchBanner(pageNum, pageSize);
    }

    /**
     * 删除轮播图
     *
     * @param id
     * @return
     */
    @PostMapping("/delBanner")
    public ResponseResult delBanner(String id) {
        return researchManagerService.delBanner(id);
    }

    /**
     * 添加轮播图
     *
     * @param bannerType    图片类型
     * @param imgUrl        社区版图
     * @param popImgUrl     弹窗图
     * @param bannerExplain 版图描述
     * @param bannerId      链接类型ID
     * @param url           链接url
     * @return
     */
    @PostMapping("/addBanner")
    public ResponseResult addBanner(Integer bannerType, String imgUrl,String bannerName, String popImgUrl, String bannerExplain, String bannerId, String url,String sort) {
        return researchManagerService.addBanner(bannerType, imgUrl,bannerName, popImgUrl, bannerExplain, bannerId, url,sort);
    }

    /**
     * 添加轮播图
     *
     * @param bannerType    图片类型
     * @param imgUrl        社区版图
     * @param popImgUrl     弹窗图
     * @param bannerExplain 版图描述
     * @param bannerId      链接类型ID
     * @param url           链接url
     * @return
     */
    @PostMapping("/updateBanner")
    public ResponseResult updateBanner(Integer id,Integer bannerType, String imgUrl,String bannerName, String popImgUrl, String bannerExplain, String bannerId, String url,String sort) {
        return researchManagerService.updateBanner(id,bannerType, imgUrl,bannerName, popImgUrl, bannerExplain, bannerId, url,sort);
    }

    /**
     * 活动帖子列表
     * @return
     * @throws Exception
     */
    @PostMapping("/researchActiveList")
    public ResponseResult researchActiveList()throws Exception{
        return researchManagerService.researchActiveList();
    }

    /**
     * 帖子活动运营数据
     * @param researchId
     * @param activeType
     * @return
     * @throws Exception
     */
    @PostMapping("/researchActiveData")
    public ResponseResult researchActiveData(String researchId,@RequestParam(value = "activeType") List<Integer> activeType) throws Exception {
        return researchManagerService.researchActiveData(researchId, activeType);
    }
    /**
     * 帖子活动运营数据总数
     * @param researchId
     * @param activeType
     * @return
     * @throws Exception
     */
    @PostMapping("/activeDateNumber")
    public ResponseResult activeDateNumber(String researchId,List<Integer> activeType) throws Exception{
        return researchManagerService.activeDateNumber(researchId, activeType);
    }
}
